package com.yvdelx.cyclowomen.object;

import com.yvdelx.cyclowomen.exception.CstException;
import com.yvdelx.cyclowomen.exception.FunctionalException;

import org.simpleframework.xml.Element;

import static com.yvdelx.cyclowomen.utility.StringUtility.CST_XML_DATA_NATURE_ELEMENT;
import static com.yvdelx.cyclowomen.utility.StringUtility.compareStrings;

/**
 * Enum object Nature
 * Created by ydelvaux on 22/02/14.
 */
public enum EnumNature {

    HIGH_POINT("HIGH_POINT"),
    LOW_POINT("LOW_POINT");

    @Element(name=CST_XML_DATA_NATURE_ELEMENT, type=String.class)
    private String nature;

    EnumNature(String nature){
        this.nature = nature;
    }

    @Override
    public String toString(){
        return this.nature;
    }

    @SuppressWarnings("unused")
    public static EnumNature getEnumNature(String nature) throws FunctionalException {
        if(compareStrings(nature, HIGH_POINT.toString())){
            return HIGH_POINT;
        } else if(compareStrings(nature, LOW_POINT.toString())){
            return LOW_POINT;
        } else {
            throw new FunctionalException(CstException.CST_NATURE_NULL);
        }
    }

    public Boolean isHighPoint(){
        return this.equals(EnumNature.HIGH_POINT);
    }
}
